/**
  ******************************************************************************
  * @file    app_alarm.h
  * @author  Sherlock
  * @version V0.1
  * @date    9/18/2024
  * @brief   Alarm handling head file.
  ******************************************************************************
  * @copy
  *
  * <h2><center>&copy; COPYRIGHT 2010 Feirui</center></h2>
  */ 



/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef  __APP_ALARM_H__
#define  __APP_ALARM_H__

#ifdef __cplusplus
 extern "C" {
#endif

/**
  * @brief GLOBALS RAM definition
  */
#ifdef   APP_GLOBALS_ALARM
#define  APP_EXT_ALARM
#else
#define  APP_EXT_ALARM  extern
#endif


/**
  * @brief  INCLUDE FILES.
  */


#define OSALARMFlags_GenFreqTiming                         ((OS_FLAGS)DEF_BIT_00)
#define OSALARMFlags_LoadFreqTiming                        ((OS_FLAGS)DEF_BIT_01)
#define OSALARMFlags_GenVoltTiming                         ((OS_FLAGS)DEF_BIT_02)
#define OSALARMFlags_LoadVoltTiming                        ((OS_FLAGS)DEF_BIT_03)
#define OSALARMFlags_GenCurrTiming                         ((OS_FLAGS)DEF_BIT_04)
#define OSALARMFlags_GenExciteTiming                       ((OS_FLAGS)DEF_BIT_05)
#define OSALARMFlags_LoadExciteTiming                      ((OS_FLAGS)DEF_BIT_06)
#define OSALARMFlags_SyncTiming                            ((OS_FLAGS)DEF_BIT_07)
#define OSALARMFlags_PowerTiming                           ((OS_FLAGS)DEF_BIT_08)

#define OSACADFlags_TIMING                         (OSALARMFlags_GenFreqTiming   |\
                                                    OSALARMFlags_LoadFreqTiming  |\
                                                    OSALARMFlags_GenVoltTiming   |\
                                                    OSALARMFlags_LoadVoltTiming  |\
                                                    OSALARMFlags_GenCurrTiming   |\
                                                    OSALARMFlags_GenExciteTiming |\
                                                    OSALARMFlags_LoadExciteTiming|\
                                                    OSALARMFlags_SyncTiming      |\
                                                    OSALARMFlags_PowerTiming     )
#define OSALARMFlags_ALL                            (OSACADFlags_TIMING)
#define OSALARMFlags_DefaultValue                   ((OS_FLAGS)0x00000000)


APP_EXT_ALARM uint16_t Alarm_RTGlobalData;
typedef enum
{
    // AlarmType_GenFreqLow      = DEF_BIT_00,   //被测电机低频告警
    // AlarmType_LoadFreqLow     = DEF_BIT_01,   //负载电机低频告警
    AlarmType_GenVoltHigh     = DEF_BIT_01,   //发电过电压告警
    AlarmType_GenCurrHigh     = DEF_BIT_02,   //发电过流告警
    AlarmType_AcPowerHigh     = DEF_BIT_03,   //有功功率过高告警
    AlarmType_RePowerHigh     = DEF_BIT_04,   //无功功率过高告警
    AlarmType_GenExVoltHigh   = DEF_BIT_05,   //AVR励磁过流告警
    AlarmType_GenExCurrHigh   = DEF_BIT_06,   //AVR励磁过流告警
    AlarmType_GenPFLow        = DEF_BIT_07,   //功率因数低告警
    AlarmType_Reserved8       = DEF_BIT_08,   //
    AlarmType_LoadVoltHigh    = DEF_BIT_09,   //负载电机过电压告警
    AlarmType_LoadExVoltHigh  = DEF_BIT_10,   //负载电机励磁过流告警
    AlarmType_LoadExCurrHigh  = DEF_BIT_11,   //负载电机励磁过流告警
    AlarmType_SyncLoss        = DEF_BIT_12,   //失步告警
    AlarmType_Reserved13      = DEF_BIT_13,   //
    // AlarmType_NegativeAcPower = DEF_BIT_10,   //逆有功功率告警
    // AlarmType_PFLow           = DEF_BIT_11,   //功率因数过低告警
} AlarmType;

uint16_t Alarm_GetTotalAlarm(void);
uint8_t Alarm_GetAlarmStatus(AlarmType alarmName);



#ifdef __cplusplus
}
#endif

#endif   /*  __APP_ALARM_H__  */

/******************* (C) COPYRIGHT 2010 Feirui *****END OF FILE****/